#ifndef ROUTE_TRAINER_MANAGER_H
#define ROUTE_TRAINER_MANAGER_H

#include "RouteTrainDisplayInfo.h"
#include "time_period.h"
#include "positionmanager.h"
#include <QJsonObject>
#include <QString>
#include <QMap>
#include <QThread>
#include <Windows.h>

class RouteTrainerManager
{
public:
    RouteTrainerManager();

    bool loadRoutePositions();
    int startTrain(PositionManager* positionManager);
    QList<RouteTrainDisplayInfo*> * endTrainByOtherThread(bool needDisplayInfo);


private:
    bool isTrackThreadRun;
    QThread * trackThread = NULL;

    PositionManager* positionManager;
    QList<QJsonObject> positionInfoList;

    bool isRoleStartRunning;
    int lastNearestPosIdx;
    bool isLastRoleInClimbOrStop;
    long long lastClimbOrStopStartTimeMS;
    QList<TimePeriod> climbOrStopSegmentList;

    int trackPosition();
    QList<RouteTrainDisplayInfo*>* resolveRouteTrainDisplayInfoList(bool ended);
};

#endif // ROUTE_TRAINER_MANAGER_H
